home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0216_Re: tMemo co-ordinates.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-03-04  |  934 b   |  44 lines

  1.  
  2. unit Memos;
  3.  
  4. interface
  5.  
  6. uses WinProcs, SysUtils, StdCtrls, Dialogs, Message;
  7.  
  8. { Get the line number and column number the cursor is positioned at in the
  9. memo}
  10.  
  11. Procedure GetMemoLineCol (Memo: TCustomMemo; var MemoLine, MemoCol:
  12. Integer);
  13.  
  14. { Set the cursor position in a memo to the specified line and column }
  15.  
  16. Procedure MemoCursorTo (Memo: TCustomMemo; MemoLine, MemoCol: Integer);
  17.  
  18. Implementation
  19.  
  20. Procedure GetMemoLineCol;
  21. begin
  22.    WITH Memo DO
  23.       BEGIN
  24.          MemoLine := SendMessage (Handle, EM_LINEFROMCHAR, SelStart, 0);
  25.          MemoCol  := SelStart - SendMessage (Handle, EM_LINEINDEX, MemoLine,
  26.                       0) + 1;
  27.       END;
  28. end;
  29.  
  30. Procedure MemoCursorTo;
  31. begin
  32.    Memo.SelStart := SendMessage (Memo.Handle, EM_LINEINDEX, MemoLine, 0) +
  33.                    MemoCol - 1;
  34. end;
  35.  
  36.  
  37. Ronan van Riet
  38.  
  39. Graaf Florishof 4
  40. 3632 BS Loenen a/d Vecht
  41. The Netherlands
  42. 0294-233563
  43.  
  44.